/* 坐席端-我的录音
改版自-录音库相关
---------------------------------------------------------------- */
import $http from '../../../servers/http';
import { Result } from 'seats/schema/Result';
import {
  CreateSeatSoundTempRequest,
  EditSeatSoundTempRequest,
  SeatSoundTempRequest,
  SeatSoundRecordInfo,
  SeatSoundRecordRequest,
  SeatSoundTempResponse,
} from 'seats/schema/SoundManage';

/**
 * 查询录音模板列表
 * @param data SeatSoundTempRequest
 */
export const getSeatSoundTempList = (
  data: SeatSoundTempRequest
): Promise<Result<SeatSoundTempResponse[]>> => {
  return $http.get({
    url: '/seats/soundrecordtemplates',
    data,
  });
};

/**
 * 创建录音模板
 * @param data CreateSeatSoundTempRequest
 */
export const createSeatSoundTemp = (
  data: CreateSeatSoundTempRequest
): Promise<Result<{ templateId: number }>> => {
  return $http.post({
    url: '/seats/soundrecordtemplates',
    data,
  });
};

/**
 * 修改录音模板
 * @param templateId
 * @param data EditSeatSoundTempRequest
 */
export const editSeatSoundTemp = (
  templateId: number,
  data: EditSeatSoundTempRequest
): Promise<Result<null>> => {
  return $http.put({
    url: `/seats/soundrecordtemplates/${templateId}`,
    data,
  });
};

/**
 * 查询录音模板详情
 * @param data SeatSoundTempRequest
 */
export const getSeatSoundTempInfo = (
  templateId: number
): Promise<Result<SeatSoundTempResponse>> => {
  return $http.get({
    url: `/seats/soundrecordtemplates/${templateId}`,
  });
};

/**
 * 查询录音模板-话术列表--管理端-机器人-话术列表-接口
 * @param data SeatSoundRecordRequest
 */
export const getSeatSoundRecordList = (
  data: SeatSoundRecordRequest
): Promise<Result<{ list: SeatSoundRecordInfo[]; filePath: string }>> => {
  return $http.get({
    url: '/robotmanage/soundrecords',
    data,
  });
};

/**
 * 录音库-上传录音
 * @param soundRecordId
 * @param data
 */
export const uploadSeatSoundRecord = (soundRecordId: number, data: any): Promise<Result<null>> => {
  return $http.post({
    url: `/seats/soundrecords/upload/${soundRecordId}`,
    data,
  });
};
